<?php


namespace App\Http\Controllers\Api;


use App\Services\BidService;
use Illuminate\Http\Request;

class BidController extends BaseController
{

    /**
     * @api {post} api/bid/store 创建
     *
     * @param Request $request
     * @param BidService $service
     * @return mixed
     * @throws \Throwable
     */
    public function store(Request $request, BidService $service) {
        return $service->store($request->input());
    }

    /**
     * @api {delete} api/bid/destroy/{id} 删除
     *
     * @param BidService $service
     * @param $id
     * @return bool|mixed|null
     * @throws \Exception
     */
    public function destroy(BidService $service, $id){
        return $service->destroy($id);
    }

    /**
     * @api {post} api/bid/update/{id} 更新
     *
     * @param Request $request
     * @param BidService $service
     * @param null $id
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|\Tymon\JWTAuth\Contracts\JWTSubject|null
     * @throws \Exception
     */
    public function update(Request $request, BidService $service, $id = null) {
        return $service->update($request->input(), $this->manager ? $id : \Auth::id());
    }

    /**
     * @api {get} api/bid/info/{id} 信息
     *
     * @param Request $request
     * @param BidService $service
     * @param null $id
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|\Tymon\JWTAuth\Contracts\JWTSubject|null
     * @throws \Exception
     */
    public function show(BidService $service, $id = null) {
        return $service->show($id);
    }

    /**
     * @api {get} api/bid/active 信息
     *
     * @param Request $request
     * @param BidService $service
     * @param null $id
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|\Tymon\JWTAuth\Contracts\JWTSubject|null
     * @throws \Exception
     */
    public function showActive(BidService $service) {
        return $service->showActive();
    }

    /**
     * @api {get} api/bid/paginate 分页
     *
     * @param Request $request
     * @param BidService $service
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
     */
    public function index(Request $request, BidService $service) {
        return $service->index($request->query());
    }
}
